﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows;

namespace Gronia.WPF.Controls
{
    public class ConnectPoint
    {
        public ConnectionChild Parent { get; private set; }

        public Point GetPosition()
        {
            int index = -1;
            index = Parent.InputPoints.IndexOf(this);
            if (index == -1)
            {
                index = Parent.OutputPoints.IndexOf(this);
                if (index != -1)
                {
                    return new Point(Parent.Position.X + Parent.Width, Parent.Position.Y + index * 15 + 5);
                }
            }
            else
            {
                return new Point(Parent.Position.X, Parent.Position.Y + index * 15 + 5);
            }
            return new Point(0, 0);
        }

        public static ConnectPoint Create(ConnectionChild container)
        {
            return new ConnectPoint() { Parent = container };
        }

        private ConnectPoint() { }
    }
}